/**
* 系统管理 用户管理
*/
<template>
	<div>
		<!-- 面包屑导航 -->
		<el-breadcrumb separator-class="el-icon-arrow-right">
			<el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
			<el-breadcrumb-item>用户管理</el-breadcrumb-item>
		</el-breadcrumb>
		<!-- 搜索筛选 -->
		<el-form :inline="true" :model="formInline" class="user-search">
			<!-- <el-form-item label="搜索：">
			<el-select size="small" v-model="formInline.isLock" placeholder="请选择">
			  <el-option label="全部" value=""></el-option>
			  <el-option label="正常" value="N"></el-option>
			  <el-option label="已锁定" value="Y"></el-option>
			</el-select>
		  </el-form-item> -->
			<el-form-item label="">
				<el-input size="small" v-model="formInline.userName" placeholder="输入用户名"></el-input>
			</el-form-item>
			<el-form-item label="">
				<el-input size="small" v-model="formInline.userState" placeholder="输入查询状态"></el-input>
			</el-form-item>
			<el-form-item>
				<el-button size="small" type="primary" icon="el-icon-search" @click="search">搜索</el-button>
				<el-button size="small" type="primary" icon="el-icon-plus" @click="handleAdd()">添加</el-button>
				<!-- <el-button size="small" type="primary" @click="handleunit()">用户权限</el-button> -->
			</el-form-item>
		</el-form>
		<!--列表-->
		<el-table size="small" @selection-change="selectChange" :data="userData" highlight-current-row v-loading="loading"
		 border element-loading-text="拼命加载中" style="width: 100%;">
			<el-table-column align="center" type="selection" width="50">
			</el-table-column>
			<el-table-column align="center" sortable prop="id" label="用户编号" width="120">
			</el-table-column>
			<el-table-column align="center" sortable prop="userName" label="用户账号" width="120">
			</el-table-column>
			<el-table-column align="center" sortable prop="userPwd" label="用户密码" width="120">
			</el-table-column>
			<el-table-column align="center" sortable prop="userState" label="用户状态" width="120">
			</el-table-column>
			<el-table-column align="center" sortable prop="creator" label="创建人" min-width="50">
			</el-table-column>
			<el-table-column align="center" sortable prop="createTime" label="创建时间" min-width="120">
			</el-table-column>
			<el-table-column align="center" sortable prop="isDeleted" label="是否删除" min-width="120">

			</el-table-column>
			<el-table-column align="center" sortable prop="userState" label="状态" min-width="50">
				<template slot-scope="scope">
					<!-- <el-switch v-model="scope.row.isLock=='N'?nshow:fshow" active-color="#13ce66" inactive-color="#ff4949" @change="editType(scope.$index, scope.row)">
					</el-switch> -->
					<el-switch v-model="scope.row.userState=='1'?nshow:fshow" active-color="#13ce66" inactive-color="#ff4949" @change="editType(scope.$index, scope.row)">
					</el-switch>
				</template>
			</el-table-column>
			<el-table-column label="操作" fixed="right" min-width="300">
				<template slot-scope="scope">
					<el-button size="mini" @click="handleEdit(scope.$index, scope.row)">编辑</el-button>
					<el-button size="mini" type="danger" @click="deleteUser(scope.$index, scope.row)">删除</el-button>
					<el-button size="mini" type="success" @click="resetpwd(scope.$index, scope.row)">重置密码</el-button>
					<el-button size="mini" type="success" @click="dataAccess(scope.$index, scope.row)">数据权限</el-button>
					<!-- <el-button size="mini" type="success" @click="offlineUser(scope.$index, scope.row)">下线</el-button> -->
					<!-- <el-button size="mini" type="success" @click="refreshCache(scope.$index, scope.row)">刷新缓存</el-button> -->
				</template>
			</el-table-column>
		</el-table>
		<!-- 分页组件 -->
		<Pagination v-bind:child-msg="pageparm" @callFather="callFather"></Pagination>
		<!-- 编辑界面 -->
		<el-dialog :title="title" :visible.sync="editFormVisible" width="30%" @click='closeDialogedit("edit")'>
			<el-form label-width="80px" ref="editForm" :model="editForm" :rules="rules">
				<el-form-item label="用户名" prop="userName">
					<el-input size="small" v-model="editForm.userName" auto-complete="off" placeholder="请输入用户名"></el-input>
				</el-form-item>
				<el-form-item label="密码" prop="userPwd">
					<el-input size="small" v-model="editForm.userPwd" auto-complete="off" placeholder="请输入密码"></el-input>
				</el-form-item>
				<!-- <el-form-item label="状态" prop="userState">
          <el-select size="small" v-model="editForm.userState" placeholder="请选择" class="userRole">
            <el-option label="公司管理员" value="1"></el-option>
            <el-option label="普通用户" value="2"></el-option>
          </el-select>
        </el-form-item> -->
				<el-form-item label="状态" prop="userState">
					<el-input size="small" v-model="editForm.userState" auto-complete="off" placeholder="请输入状态"></el-input>
				</el-form-item>
				<el-form-item label="创建人" prop="creator">
					<el-input size="small" v-model="editForm.creator" placeholder="请输入创建人"></el-input>
				</el-form-item>
				<!-- <el-form-item label="创建时间" prop="createTime">
          <el-input size="small" v-model="editForm.createTime" placeholder="请输入邮箱地址"></el-input>
        </el-form-item> -->
				<el-form-item label="创建时间">

					<el-date-picker type="date" placeholder="选择日期" v-model="editForm.createTime" style="width: 100%;"></el-date-picker>

				</el-form-item>
				<el-form-item label="是否删除" prop="isDeleted">
					<el-input size="small" v-model="editForm.isDeleted" placeholder="请输入是否删除"></el-input>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button size="small" @click='closeDialogedit("edit")'>取消</el-button>
				<el-button size="small" type="primary" :loading="loading" class="title" @click="submitFormEdit('editForm')">保存</el-button>
			</div>
		</el-dialog>

		<!-- 添加界面 -->
		<el-dialog :title="title" :visible.sync="addFormVisible" width="30%" @click='closeDialogadd("edit")'>
			<el-form label-width="80px" ref="editForm" :model="editForm" :rules="rules">
				<el-form-item label="用户名" prop="userName">
					<el-input size="small" v-model="editForm.userName" auto-complete="off" placeholder="请输入用户名"></el-input>
				</el-form-item>
				<el-form-item label="密码" prop="userPwd">
					<el-input size="small" v-model="editForm.userPwd" auto-complete="off" placeholder="请输入密码"></el-input>
				</el-form-item>
				<!-- <el-form-item label="状态" prop="userState">
          <el-select size="small" v-model="editForm.userState" placeholder="请选择" class="userRole">
            <el-option label="公司管理员" value="1"></el-option>
            <el-option label="普通用户" value="2"></el-option>
          </el-select>
        </el-form-item> -->
				<el-form-item label="状态" prop="userState">
					<el-input size="small" v-model="editForm.userState" auto-complete="off" placeholder="请输入状态"></el-input>
				</el-form-item>
				<el-form-item label="创建人" prop="creator">
					<el-input size="small" v-model="editForm.creator" placeholder="请输入创建人"></el-input>
				</el-form-item>
				<!-- <el-form-item label="创建时间" prop="createTime">
          <el-input size="small" v-model="editForm.createTime" placeholder="请输入邮箱地址"></el-input>
        </el-form-item> -->
				<el-form-item label="创建时间">

					<el-date-picker type="date" placeholder="选择日期" v-model="editForm.createTime" style="width: 100%;"></el-date-picker>

				</el-form-item>
				<el-form-item label="是否删除" prop="isDeleted">
					<el-input size="small" v-model="editForm.isDeleted" placeholder="请输入是否删除"></el-input>
				</el-form-item>
			</el-form>
			<div slot="footer" class="dialog-footer">
				<el-button size="small" @click='closeDialogadd("edit")'>取消</el-button>
				<el-button size="small" type="primary" :loading="loading" class="title" @click="submitFormAdd('editForm')">保存</el-button>
			</div>
		</el-dialog>
		<!-- 数据权限 -->
		<el-dialog title="数据权限" :visible.sync="dataAccessshow" width="50%" @click='closeDialog("perm")'>

			<!-- 
			<el-tree ref="tree" default-expand-all="" :data="UserDept" :props="defaultProps" :default-checked-keys="checkmenu"
			 node-key="id" show-checkbox>
			</el-tree> -->
			<!-- 穿梭框 -->
			<template>
				<el-transfer v-model="value" :data="data"></el-transfer>
			</template>
			<div slot="footer" class="dialog-footer">
				<el-button size="small" @click='closeDialog("perm")'>取消</el-button>
				<el-button size="small" type="primary" :loading="loading" class="title" @click="menuPermSave">保存</el-button>
			</div>
		</el-dialog>
		<!-- 所属单位 -->
		<!-- 	<el-dialog title="数据权限" :visible.sync="unitAccessshow" width="30%" @click='closeDialog("unit")'>
			<el-tree ref="tree" default-expand-all="" :data="UserDept" :props="defaultProps" @check-change="handleClick"
			 :default-checked-keys="checkmenu" node-key="id" show-checkbox check-strictly>
			</el-tree>
			<div slot="footer" class="dialog-footer">
				<el-button size="small" @click='closeDialog("unit")'>取消</el-button>
				<el-button size="small" type="primary" :loading="loading" class="title" @click="unitPermSave">保存</el-button>
			</div>
		</el-dialog> -->
	</div>
</template>

<script>
	// 导入请求方法
	import {
		userList,
		useredit,
		userSave,
		usereditid,
		userDelete,
		userPwd,
		userExpireToken,
		userFlashCache,
		userLock,
		UserDeptTree,
		UserDeptSave,
		UserDeptdeptTree,
		UserChangeDept
	} from '../../api/userMG'
	import Pagination from '../../components/Pagination'
	export default {
		data() {
			const generateData = _ => {
				const data = [];
				for (let i = 1; i <= 15; i++) {
					data.push({
						key: i,
						label: `备选项 ${ i }`,
						//disabled: i % 4 === 0
					});
				}
				return data;
			};
			return {
				data: generateData(),
				value: [1, 6],
				// UserDept: [{
				// 	id: 0,
				// 	label: '一级 1',
				// 	children: [{
				// 		id: 4,
				// 		label: '二级 1-1',
				// 		children: [{
				// 			id: 9,
				// 			label: '三级 1-1-1'
				// 		}, {
				// 			id: 10,
				// 			label: '三级 1-1-2'
				// 		}]
				// 	}]
				// }, {
				// 	id: 2,
				// 	label: '一级 2',
				// 	children: [{
				// 		id: 5,
				// 		label: '二级 2-1'
				// 	}, {
				// 		id: 6,
				// 		label: '二级 2-2'
				// 	}]
				// }, {
				// 	id: 3,
				// 	label: '一级 3',
				// 	children: [{
				// 		id: 7,
				// 		label: '二级 3-1'
				// 	}, {
				// 		id: 8,
				// 		label: '二级 3-2'
				// 	}]
				// }],
				addFormVisible: false,
				nshow: true, //switch开启
				fshow: false, //switch关闭
				loading: false, //是显示加载
				title: '添加用户',
				editFormVisible: false, //控制编辑页面显示与隐藏
				dataAccessshow: false, //控制数据权限显示与隐藏
				unitAccessshow: false, //控制所属单位隐藏与显示
				// 编辑与添加
				editForm: {
					id: '',
					userName: '',
					userPwd: '',
					userState: '',
					creator: '',
					createTime: '',
					isDeleted: '',
					//token: localStorage.getItem('logintoken')
				},
				// 部门参数
				// unitparm: {
				// 	userIds: '',
				// 	deptId: '',
				// 	deptName: ''
				// },
				// 选择数据
				selectdata: [],
				// rules表单验证
				rules: {
					userName: [{
						required: true,
						message: '请输入用户名',
						trigger: 'blur'
					}],
					userPwd: [{
						required: true,
						message: '请输入密码',
						trigger: 'blur'
					}],
					userState: [{
						required: true,
						message: '请选择状态0、1、2',
						trigger: 'blur'
					}],
					creator: [{
							required: true,
							message: '请输入创建人',
							trigger: 'blur'
						},
						// {
						//   pattern: /^1(3\d|47|5((?!4)\d)|7(0|1|[6-8])|8\d)\d{8,8}$/,
						//   required: true,
						//   message: '请输入正确的手机号',
						//   trigger: 'blur'
						// }
					],
					// userEmail: [
					//   { required: true, message: '请输入邮箱', trigger: 'blur' },
					//   {
					//     pattern: /^[A-Za-z0-9\u4e00-\u9fa5]+@[a-zA-Z0-9_-]+(\.[a-zA-Z0-9_-]+)+$/,
					//     required: true,
					//     message: '请输入正确的邮箱',
					//     trigger: 'blur'
					//   }
					// ],
					isDeleted: [{
						required: true,
						message: '请选择删除状态',
						trigger: 'blur'
					}]
				},
				// 删除用户
				// seletedata: {
				// 	ids: '',
				// 	token: localStorage.getItem('logintoken')
				// },
				// // 重置密码
				resetpsd: {
					id: '',
					//token: localStorage.getItem('logintoken')
				},
				// // 用户下线
				// offline: {
				// 	token: localStorage.getItem('logintoken')
				// },
				// 请求数据参数
				formInline: {
					// page: 1,
					// limit: 10,
					// deptId: '',
					userName: '',
					userState: '',

					// userMobile: '',
					// isLock: ''
				},
				//用户数据
				userData: [],
				// 数据权限
				UserDept: [


				],
				defaultProps: {
					children: 'children',
					label: 'userName'
				},
				// 选中
				checkmenu: [],
				//参数role
				saveroleId: '',
				// 分页参数
				pageparm: {
					currentPage: 1,
					pageSize: 10,
					total: 10
				}
			}
		},
		// 注册组件
		components: {
			Pagination
		},

		/**
		 * 数据发生改变
		 */
		watch: {},

		/**
		 * 创建完毕
		 */
		created() {
			this.getdata(this.formInline)
		},

		/**
		 * 里面的方法只有被调用才会执行
		 */
		methods: {
			// 获取数据方法
			getdata(parameter) {

				// this.loading = false
				// this.userData = res.data
				// // 分页赋值
				// this.pageparm.currentPage = this.formInline.page
				// this.pageparm.pageSize = this.formInline.limit
				// this.pageparm.total = res.count
				// // 模拟数据结束

				/***
				 * 调用接口，注释上面模拟数据 取消下面注释
				 */
				//获取用户列表
				userList(this.formInline).then(res => {
					console.log(res)
					this.loading = false
					if (res.success == false) {
						this.$message({
							type: 'info',
							message: res.msg
						})
					} else {
						this.userData = res
						// 分页赋值
						this.pageparm.currentPage = this.formInline.page
						this.pageparm.pageSize = this.formInline.limit
						this.pageparm.total = res.count
					}
				})
			},
			// 分页插件事件
			callFather(parm) {
				this.formInline.page = parm.currentPage
				this.formInline.limit = parm.pageSize
				this.getdata(this.formInline)
			},
			//搜索事件
			search() {
				this.getdata(this.formInline)
			},
			// 修改type
			editType: function(index, row) {
				this.loading = true
				let parm = {
					lock: '',
					//userId: '',
					//token: localStorage.getItem('logintoken')
				}
				console.log(row.userState)
				//parm.userId = row.userId
				let lock = row.userState
				if (lock == '1') {
					parm.lock = '0'
				} else {
					parm.lock = '1'
				}
				// 修改状态
				userLock(row.id).then(res => {
					this.loading = false
					if (res.success == false) {
						this.$message({
							type: 'info',
							message: res.msg
						})
					} else {
						this.$message({
							type: 'success',
							message: '状态修改成功'
						})
						this.getdata(this.formInline)
					}
				})
			},
			handleAdd: function() {
				this.addFormVisible = true
				this.title = '添加用户'
				this.editForm.id = ''
				this.editForm.userName = ''
				this.editForm.userPwd = ''
				this.editForm.userState = ''
				this.editForm.creator = ''
				this.editForm.createTime = ''
				this.editForm.isDeleted = ''
			},
			//显示编辑界面
			handleEdit: function(index, row) {
				this.editFormVisible = true
				this.title = '修改用户'
				var that = this;
				usereditid(row).then((res) => {
					console.log(res);
					this.editForm.id = res.data.id
					this.editForm.userName = res.data.userName
					this.editForm.userPwd = res.data.userPwd
					this.editForm.userState = res.data.userState
					this.editForm.creator = res.data.creator
					this.editForm.createTime = res.data.createTime
					this.editForm.isDeleted = res.data.isDeleted
					//this.editForm.id=res.id
				})
				// this.title = '修改用户'
				// this.editForm.id = row.id
				// this.editForm.userName = row.userName
				// this.editForm.userPwd = row.userPwd
				// this.editForm.userState = row.userState
				// this.editForm.creator = row.creator
				// this.editForm.createTime = row.createTime
				// this.editForm.isDeleted = row.isDeleted

			},
			//添加提交方法
			submitFormAdd(editData) {
				this.$refs[editData].validate(valid => {
					if (valid) {
						// 请求方法
						userSave(this.editForm)
							.then(res => {
								this.editFormVisible = false
								this.loading = false
								if (res.success) {
									this.getdata(this.formInline)
									this.$message({
										type: 'success',
										message: '数据保存成功！'
									})
								} else {
									this.$message({
										type: 'info',
										message: res.msg
									})
								}
							})
							.catch(err => {
								this.editFormVisible = false
								this.loading = false
								this.$message.error('保存失败，请稍后再试！')
							})
					} else {
						return false
					}
				})
			},
			// 编辑提交方法
			submitFormEdit(editData) {
				this.$refs[editData].validate(valid => {
					if (valid) {
						// 请求方法
						useredit(this.editForm)
							.then(res => {
								this.editFormVisible = false
								this.loading = false
								if (res.success) {
									this.getdata(this.formInline)
									this.$message({
										type: 'success',
										message: '数据保存成功！'
									})
								} else {
									this.$message({
										type: 'info',
										message: res.msg
									})
								}
							})
							.catch(err => {
								this.editFormVisible = false
								this.loading = false
								this.$message.error('保存失败，请稍后再试！')
							})
					} else {
						return false
					}
				})
			},

			// 显示部门设置
			handleunit: function(index, row) {
				this.unitAccessshow = true
				let parms = 0
				UserDeptdeptTree(parms)
					.then(res => {
						if (res.data.success) {
							this.UserDept = this.changeArr(res.data.data)
						} else {
							this.$message({
								type: 'info',
								message: res.msg
							})
						}
					})
					.catch(err => {
						this.loading = false
						this.$message.error('配置权限失败,请稍后再试！')
					})
			},
			handleClick(data, checked, node) {
				if (checked) {
					this.$refs.tree.setCheckedNodes([])
					this.$refs.tree.setCheckedNodes([data])
					this.unitparm.deptId = data.id
					this.unitparm.deptName = data.name
					//交叉点击节点
				} else {}
			},
			// 保存部门
			unitPermSave() {
				let len = this.selectdata
				let ids = []
				if (len != 0) {
					for (let i = 0; i < len.length; i++) {
						ids.push(len[i].userId)
					}
				}
				this.unitparm.userIds = ids.join(',')
				UserChangeDept(this.unitparm)
					.then(res => {
						this.unitAccessshow = false
						if (res.success) {
							this.$message({
								type: 'success',
								message: '部门设置成功！'
							})
							this.getdata(this.formInline)
						} else {
							this.$message({
								type: 'info',
								message: res.msg
							})
						}
					})
					.catch(err => {
						this.loading = false
						this.$message.error('部门设置失败,请稍后再试！')
					})
			},
			// 选择复选框事件
			selectChange(val) {
				this.selectdata = val
			},
			closeDialogadd(dialog) {
				this.addFormVisible = false
			},
			closeDialogedit(dialog) {
				this.editFormVisible = false
			},
			// 关闭编辑、增加弹出框
			closeDialog(dialog) {
				if (dialog == 'edit') {
					this.editFormVisible = false
				} else if (dialog == 'perm') {
					this.dataAccessshow = false
				} else if (dialog == 'unit') {
					this.unitAccessshow = false
				}
			},
			// 删除用户
			deleteUser(index, row) {
				this.$confirm('确定要删除吗?', '信息', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					})
					.then(() => {
						// 删除
						userDelete(row.id)						
							.then(res => {
								console.log(res)
								if (res.success) {
									this.$message({
										type: 'success',
										message: '数据已删除!'
									})
									this.getdata(this.formInline)
								} else {
									this.$message({
										type: 'info',
										message: res.msg
									})
								}
							})
							.catch(err => {
								this.loading = false
								this.$message.error('数据删除失败，请稍后再试！')
							})
					})
					.catch(() => {
						this.$message({
							type: 'info',
							message: '已取消删除！'
						})
					})
			},
			// 重置密码
			resetpwd(index, row) {
				//this.resetpsd.userId = row.userId
				this.$confirm('确定要重置密码吗?', '信息', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					})
					.then(() => {
						userPwd(row.id)
							.then(res => {
								console.log(res)
								if (res.success) {
									this.$message({
										type: 'success',
										message: '重置密码成功！',

									})
									console.log(123456)
									this.getdata(this.formInline)

								} else {
									this.$message({
										type: 'info',
										message: res.msg
									})

								}
							})
							.catch(err => {
								this.loading = false
								this.$message.error('重置密码失败，请稍后再试！')
							})
					})
					.catch(() => {
						this.$message({
							type: 'info',
							message: '取消重置密码！'
						})
					})
			},
			// 数据权限
			
			
			dataAccess: function(index, row) {


				console.log("=============================================")
				console.log(this.userData)
				this.dataAccessshow = true
				//this.saveroleId = row.userId
				UserDeptTree(row)
					.then(res => {
						console.log(res)
						if (res.data.success) {
							this.checkmenu = this.changemenu(res.data.data)
							this.UserDept = this.changeArr(res.data.data)
						} else {
							this.$message({
								type: 'info',
								message: res.data.msg
							})
						}
					})
					.catch(err => {
						this.loading = false
						this.$message.error('获取权限失败，请稍后再试！')
					})
			},
			//数据格式化
			changeArr(data) {
				var pos = {}
				var tree = []
				var i = 0
				while (data.length != 0) {
					if (data[i].pId == 0) {
						tree.push({
							id: data[i].id,
							name: data[i].name,
							pId: data[i].pId,
							open: data[i].open,
							checked: data[i].checked,
							children: []
						})
						pos[data[i].id] = [tree.length - 1]
						data.splice(i, 1)
						i--
					} else {
						var posArr = pos[data[i].pId]
						if (posArr != undefined) {
							var obj = tree[posArr[0]]
							for (var j = 1; j < posArr.length; j++) {
								obj = obj.children[posArr[j]]
							}

							obj.children.push({
								id: data[i].id,
								name: data[i].name,
								pId: data[i].pId,
								open: data[i].open,
								checked: data[i].checked,
								children: []
							})
							pos[data[i].id] = posArr.concat([obj.children.length - 1])
							data.splice(i, 1)
							i--
						}
					}
					i++
					if (i > data.length - 1) {
						i = 0
					}
				}
				return tree
			},
			// 选中菜单
			changemenu(arr) {
				let change = []
				for (let i = 0; i < arr.length; i++) {
					if (arr[i].checked) {
						change.push(arr[i].id)
					}
				}
				return change
			},
			// 菜单权限-保存
			menuPermSave() {
				let parm = {
					userId: this.saveroleId,
					deptIds: ''
				}
				let node = this.$refs.tree.getCheckedNodes()
				let moduleIds = []
				if (node.length != 0) {
					for (let i = 0; i < node.length; i++) {
						moduleIds.push(node[i].id)
					}
					parm.deptIds = JSON.stringify(moduleIds)
				}
				UserDeptSave(parm)
					.then(res => {
						if (res.success) {
							this.$message({
								type: 'success',
								message: '权限保存成功'
							})
							this.dataAccessshow = false
							this.getdata(this.formInline)
						} else {
							this.$message({
								type: 'info',
								message: res.msg
							})
						}
					})
					.catch(err => {
						this.loading = false
						this.$message.error('权限保存失败，请稍后再试！')
					})
			},
			// 下线用户
			offlineUser(index, row) {
				this.$confirm('确定要让' + row.userName + '用户下线吗?', '信息', {
						confirmButtonText: '确定',
						cancelButtonText: '取消',
						type: 'warning'
					})
					.then(() => {
						userExpireToken(row.userName)
							.then(res => {
								if (res.success) {
									this.$message({
										type: 'success',
										message: '用户' + row.userName + '强制下线成功！'
									})
									this.getdata(this.formInline)
								} else {
									this.$message({
										type: 'info',
										message: res.msg
									})
								}
							})
							.catch(err => {
								this.loading = false
								this.$message.error('用户下线失败，请稍后再试！')
							})
					})
					.catch(() => {
						this.$message({
							type: 'info',
							message: '已取消'
						})
					})
			},
			// 刷新缓存
			refreshCache(index, row) {
				userFlashCache(row.userName)
					.then(res => {
						if (res.success) {
							this.$message({
								type: 'success',
								message: '刷新成功！'
							})
							this.getdata(this.formInline)
						} else {
							this.$message({
								type: 'info',
								message: res.msg
							})
						}
					})
					.catch(err => {
						this.loading = false
						this.$message.error('刷新失败，请稍后再试！')
					})
			}
		}
	}
</script>

<style scoped>
	.user-search {
		margin-top: 20px;
	}

	.userRole {
		width: 100%;
	}
</style>
